﻿using System;
using System.Collections.Generic;
using System.Linq;
using Sustainalytics.ESGRatings.Computing.Entities.ESG;
using Sustainalytics.ESGRatings.Computing.Entities.Governance;
using CompanyData = Sustainalytics.ESGRatings.Computing.Entities.Governance.CompanyData;

namespace Sustainalytics.ESGRatings.BusinessLogic.Computing.Mappers
{
    public interface IMapper<in TK, out TResult>
    {
        TResult Map(TK source);
    }


    public interface IMapper< TU,TV,out TK>
    {
        IEnumerable<TK> Map(TU source1,IEnumerable<TV> source2,Func<TV,TU,bool> predicate);
    }

    public abstract class RegionWeightCompanyData : IMapper<RegionWeights,CompanyData,CompanyWeights>
    {
    
        public IEnumerable<CompanyWeights> Map(RegionWeights source1,IEnumerable<CompanyData> source2,Func<CompanyData,RegionWeights,bool> predicate)
        {
            IList<CompanyWeights> companyWeights = source2.Where(company=>predicate(company,source1)).Select(weight => new CompanyWeights(weight.Id, source1.IndicatorsData)).ToList();
            return companyWeights;
        }

        //private static Func<CompanyData, bool> Predicate(RegionWeights source1)
        //{
        //    return company=>company.Region.Equals(source1.Region);
        //}
      
    }


   
}
